<template>
  <div>
    <div style="display: flex">
      <div class="left">
        <el-input
            placeholder="请输入店铺名称搜索"
            suffix-icon="el-icon-search"
            size="small"
            @input="getStoreList"
            v-model="assignTaskName"
        ></el-input>
        <el-input
            placeholder="请输入店铺编码搜索"
            suffix-icon="el-icon-search"
            size="small"
            @input="getStoreList"
            v-model="assignTaskCode"
        ></el-input>
        <el-tree
            style="margin-top: 10px"
            :data="dataTree"
            ref="treeRef"
            highlight-current
            accordion
            :render-content="renderContent"
            :props="defaultProps"
            default-expand-all
            node-key="index"
            @node-click="handleNodeClick"
        ></el-tree>
      </div>
      <div
          id="app"
          style="
          overflow: hidden;
          padding-left: 20px;
          width: 70%;
          display: flex;
          flex-direction: column;
        "
      >
        <!--   搜索 searchBar-->
        <div
            class="flex"
            style="
            align-items: center;
            justify-content: space-between;
            width: 100%;
          "
            v-if="orderList"
        >
          <el-radio-group
              size="small"
              v-model="supplierType"
              style="margin-right: 20px"
              @input="getCompany"
          >
            <el-radio-button
                :label="item.type"
                v-for="(item, index) in companyList"
                :key="index"
            >{{ item.name }}
            </el-radio-button>
          </el-radio-group>
          <div>
            <el-dropdown
                @command="(command) => handleCommand(command, orderList)"
                style="margin-right: 10px; color: #303e9d"
                v-if="
                [102, 103, 104, 105, 107, 108, 123, 124, 125, 126,127].some((v) =>
                  authorityList.includes(v)
                )
              "
            >
              <el-button type="primary" size="small">
                操作<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                    command="editOrder"
                    v-if="authorityList.includes(102) && orderList.status < 9"
                >编辑
                </el-dropdown-item>
                <el-dropdown-item
                    command="applyFreeze"
                    v-if="authorityList.includes(127)"
                >申请冻结
                </el-dropdown-item>
                <!--            非装修确认订单  不需要选择仓库-->
                <el-dropdown-item
                    command="confirmOrder1"
                    v-if="
                    supplierType != 1 &&
                    orderList.supplierState == 1 &&
                    authorityList.includes(125)
                  "
                >确认订单
                </el-dropdown-item>
                <!--            装修确认订单  需要选仓库-->
                <el-dropdown-item
                    command="confirmOrder"
                    v-if="
                    supplierType == 1 &&
                    orderList.status == 0 &&
                    authorityList.includes(125)
                  "
                >确认订单
                </el-dropdown-item>
                <el-dropdown-item
                    command="startOrder"
                    v-if="
                    orderList.supplierState == 4 &&
                    authorityList.includes(126) &&
                    supplierType != 1
                  "
                >项目开工
                </el-dropdown-item>
                <el-dropdown-item
                    command="startOrder"
                    v-if="
                    orderList.status == 5 &&
                    authorityList.includes(126) &&
                    supplierType == 1
                  "
                >项目开工
                </el-dropdown-item>
                <!--            <el-dropdown-item command="confirmOrder"-->
                <!--                              v-if="authorityList.includes(125)">确认订单-->
                <!--            </el-dropdown-item>-->
                <!--            <el-dropdown-item command="startOrder"-->
                <!--                              v-if="authorityList.includes(126)">项目开工-->
                <!--            </el-dropdown-item>-->
                <!--                <el-dropdown-item command="openRecordDialog" v-if="authorityList.includes(103)">监理验收记录-->
                <!--                </el-dropdown-item>-->
                <!--                  <el-dropdown-item command="uploadCAD" v-if="authorityList.includes(104)">上传CAD</el-dropdown-item>-->
                <el-dropdown-item
                    command="commondDetail"
                    v-if="authorityList.includes(105)"
                >用户评价明细
                </el-dropdown-item
                >
                <!--                  <el-dropdown-item command="materialDetail" v-if="authorityList.includes(106)">CAD材料明细-->
                <!--                  </el-dropdown-item>-->
                <!--                  <el-dropdown-item command="cadDeatail" v-if="authorityList.includes(108)">CAD预览详情</el-dropdown-item>-->
                <el-dropdown-item
                    command="restockDetail"
                    v-if="authorityList.includes(107)"
                >补货明细
                </el-dropdown-item
                >
                <el-dropdown-item
                    command="shelvesTime"
                    v-if="authorityList.includes(123)"
                >填写货架到货时间
                </el-dropdown-item
                >
                <el-dropdown-item
                    command="chooseManager"
                    v-if="
                    authorityList.includes(124) &&
                    orderList.status < 5 &&
                    supplierType == 1
                  "
                >
                  选择项目经理
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <el-dropdown
                @command="(command) => handleCommand(command, orderList)"
                style="color: #67c23a; margin-right: 10px"
                v-if="[109,128].some((v) => authorityList.includes(v))"
            >
              <el-button type="primary" size="small">
                摄像头<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                    command="cctvBinding"
                    v-if="authorityList.includes(109)"
                >绑定摄像头
                </el-dropdown-item
                >
                <el-dropdown-item
                    command="cctvMessageList"
                    v-if="authorityList.includes(109)"
                >违规记录
                </el-dropdown-item>
                <el-dropdown-item
                    command="cctvTakeListBtn"
                    v-if="authorityList.includes(128)"
                >运营管理记录
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <el-dropdown
                @command="(command) => handleCommand(command, orderList)"
                style="margin-right: 10px; color: #cf9236"
                v-if="[115, 114, 116].some((v) => authorityList.includes(v))"
            >
              <el-button type="primary" size="small">
                预/结算<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                    command="coldChain"
                    v-if="authorityList.includes(115)"
                >预算上传
                </el-dropdown-item
                >
                <el-dropdown-item
                    command="presettlementAduit"
                    v-if="authorityList.includes(114)"
                >预结算审核
                </el-dropdown-item>
                <el-dropdown-item
                    command="settlementUpload"
                    v-if="authorityList.includes(116)"
                >结算上传
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <el-dropdown
                @command="(command) => handleCommand(command, orderList)"
                style="margin-right: 10px; color: #6788ff"
                v-if="[119, 120, 117, 118].some((v) => authorityList.includes(v))"
            >
              <el-button type="primary" size="small">
                设计<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                    command="showData"
                    v-if="authorityList.includes(119)"
                >上传设计图
                </el-dropdown-item
                >
                <el-dropdown-item
                    command="showDataFn"
                    v-if="authorityList.includes(120)"
                >上传复尺设计图
                </el-dropdown-item
                >
                <el-dropdown-item
                    command="addCad"
                    v-if="authorityList.includes(117)"
                >添加CAD上传记录
                </el-dropdown-item
                >
                <el-dropdown-item
                    command="checkCad"
                    v-if="authorityList.includes(118)"
                >CAD上传记录
                </el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
        <div
            style="display: flex; flex-direction: column; align-items: center"
            v-if="!orderList"
        >
          <el-image
              src="https://qiniushelves.jiachuangnet.com/shelf/img/V1754988859325noData.png"
          ></el-image>
          <p>暂无数据~</p>
          <el-button
              style="margin-top: 50px"
              type="primary"
              size="small"
              @click="add"
              v-if="authorityList.includes(101)"
          ><i class="el-icon-plus" style="margin-right: 5px"></i>新增订单
          </el-button>
        </div>
        <el-descriptions
            direction="vertical"
            :column="5"
            border
            style="width: 100%"
            v-loading="loading"
            v-if="orderList"
        >
          <el-descriptions-item
              label="订单编号"
              :labelStyle="{ width: '220px' }"
          >{{ orderList.assignNo || '-' }}
          </el-descriptions-item>
          <el-descriptions-item
              label="店铺名称"
              :labelStyle="{ width: '220px' }"
          >{{ orderList.storeName || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="地址" :labelStyle="{ width: '280px' }"
          >{{ orderList.address || '-' }}
          </el-descriptions-item>
          <el-descriptions-item
              label="面积(平方米)"
              :labelStyle="{ width: '220px' }"
          >{{ orderList.storeArea || '-' }}
          </el-descriptions-item>
          <el-descriptions-item
              label="门店类型"
              :labelStyle="{ width: '220px' }"
          >
            <div v-if="orderList.storeType">
              <el-tag v-if="orderList.storeType == 'F'">加盟店</el-tag>
              <el-tag v-if="orderList.storeType == 'R'">直营店</el-tag>
            </div>
          </el-descriptions-item>
          <el-descriptions-item label="所属品牌">
            <!--          brandPartyName-->
            <div v-if="orderList.brandPartyName">
              <el-tag>{{ orderList.brandPartyName }}</el-tag>
            </div>
          </el-descriptions-item>
          <el-descriptions-item label="所属公司">{{
              orderList.companyName || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="施工负责人/联系方式"
          >{{
              orderList.projectUserName || '-'
            }}{{ orderList.projectPhone || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="加盟商姓名">{{
              orderList.customerName || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="加盟商电话">{{
              orderList.storePhone || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="供应商状态">
            <el-tag v-if="orderList.supplierState && supplierType != 1"
            >{{ supplierStateMap[orderList.supplierState] }}
            </el-tag>
            <el-tag v-if="orderList.status && supplierType == 1">{{
                StateMap[orderList.status]
              }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="预结算人员">{{
              orderList.settlementName || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="设计人员">{{
              orderList.designName || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="监理/联系方式"
          >{{ orderList.chargeUserName }}{{ orderList.chargePhone }}
          </el-descriptions-item>
          <el-descriptions-item label="售后/联系方式"
          >{{ orderList.afterName }}{{ orderList.afterPhone }}
          </el-descriptions-item>
          <el-descriptions-item label="创建时间">{{
              orderList.createTime || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="公司确认时间">{{
              orderList.confirmOrderTime || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="开工时间">{{
              orderList.startConstructionTime || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="预计完工时间" v-if="supplierType != 1"
          >{{ orderList.planCompleteTime || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="装修预计完工时间"
          >{{ orderList.planEndTime || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="实际完工时间">{{
              orderList.confirmTime || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="货架到货时间">{{
              orderList.goodsShelvesTime || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="模板名称">{{
              orderList.templateName || '-'
            }}
          </el-descriptions-item>
          <!--        <el-descriptions-item label="CAD图片">-->
          <!--          <div v-if="orderList.cadUrl">-->
          <!--            <el-image-->
          <!--                style="width: 50px; height: 50px"-->
          <!--                ref="preview"-->
          <!--                :src="'https://'+orderList.cadUrl"-->
          <!--                :preview-src-list="['https://'+orderList.cadUrl]"-->
          <!--            >-->
          <!--            </el-image>-->
          <!--          </div>-->
          <!--          <div v-else>-</div>-->
          <!--        </el-descriptions-item>-->
          <el-descriptions-item label="监控画面">
            <el-dropdown v-if="orderList.serialNumber" @command="cctvOpen">
              <el-link type="primary">
                进入监控画面<i class="el-icon-arrow-down el-icon--right"></i>
              </el-link>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                    v-for="(item,index) in orderList.serialNumber"
                    :command="item"
                    :key="index"
                >{{ item }}
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-descriptions-item>
          <el-descriptions-item label="订单类型">
            <div v-if="orderList.state">
              <el-tag v-if="orderList.state == 1">报货</el-tag>
              <el-tag v-if="orderList.state == 2">补货</el-tag>
            </div>
          </el-descriptions-item>
          <el-descriptions-item label="预算金额">{{
              orderList.budgetMoney || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="结算金额">{{
              orderList.settlementMoney || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="发货仓库">{{
              orderList.areaName || '-'
            }}
          </el-descriptions-item>
          <el-descriptions-item label="下载初尺设计图">
            <el-dropdown
                @command="downEndDrawing"
                v-if="orderList.designDrawing"
            >
              <span
                  class="el-dropdown-link"
                  style="color: #66b1ff; font-size: 13px"
              >
                下载初尺图<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                    :command="item"
                    :key="index"
                    v-for="(item,index) in orderList.designDrawing.split(',')"
                >{{ item }}
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <div v-else>-</div>
          </el-descriptions-item>
          <el-descriptions-item label="下载复尺设计图">
            <el-dropdown @command="downEndDrawing" v-if="orderList.endDrawing">
              <span
                  class="el-dropdown-link"
                  style="color: #66b1ff; font-size: 13px"
              >
                下载复尺图<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                    :command="item"
                    :key="index"
                    v-for="(item,index) in orderList.endDrawing.split(',')"
                >{{ item }}
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <div v-else>-</div>
          </el-descriptions-item>
          <el-descriptions-item label="初尺">
            <el-link
                v-if="orderList.dxfUrl"
                :href="'https://' + orderList.dxfUrl"
                style="color: #66b1ff"
            >
              下载最新图纸
            </el-link>
            <div v-else>-</div>
          </el-descriptions-item>
          <el-descriptions-item label="第一次复尺">
            <el-link
                v-if="orderList.scaleDxfUrl"
                :href="'https://' + orderList.scaleDxfUrl"
                style="color: #66b1ff"
            >
              下载最新图纸
            </el-link>
            <div v-else>-</div>
          </el-descriptions-item>
          <el-descriptions-item label="第二次复尺">
            <el-link
                v-if="orderList.scaleDxfUrlTwo"
                :href="'https://' + orderList.scaleDxfUrlTwo"
                style="color: #66b1ff"
            >
              下载最新图纸
            </el-link>
            <div v-else>-</div>
          </el-descriptions-item>
          <el-descriptions-item label="第三次复尺">
            <el-link
                v-if="orderList.scaleDxfUrlThree"
                :href="'https://' + orderList.scaleDxfUrlThree"
                style="color: #66b1ff"
            >
              下载最新图纸
            </el-link>
            <div v-else>-</div>
          </el-descriptions-item>
          <el-descriptions-item label="冻结总天数">
            {{ orderList.frozenDay || '-' }}
          </el-descriptions-item>
          <el-descriptions-item label="冻结记录">
            <el-link
                style="text-decoration: underline"
                type="primary"
                @click="checkFreeze(orderList.assignName)"
            >
              查看冻结记录
            </el-link>
          </el-descriptions-item>
        </el-descriptions>
        <!--    逾期原因弹窗-->
        <el-dialog
            :visible.sync="processDialog"
            title="逾期原因"
            center
            width="30%"
        >
          <div
              style="display: flex; flex-direction: column; align-items: center"
          >
            <p style="width: 80%; margin-bottom: 15px">
              <span>项目负责人名称：{{ overdueData.responsibleName }}</span>
            </p>
            <p style="width: 80%; margin-bottom: 15px">
              <span>项目地址：{{ overdueData.address }}</span>
            </p>
            <p style="width: 80%; margin-bottom: 15px">
              <span>项目公司负责人：{{ overdueData.executorName }}</span>
            </p>
            <p style="width: 80%; margin-bottom: 15px">
              <span>项目公司联系电话：{{ overdueData.companyPhone }}</span>
            </p>
            <p style="width: 80%; margin-bottom: 15px">
              <span>逾期时间：{{ overdueData.overdueTime }}</span>
            </p>
            <p style="width: 80%; margin-bottom: 15px; color: red">
              <span>逾期原因：{{ overdueData.overdueReason }}</span>
            </p>
            <p style="width: 80%; margin-bottom: 15px; display: flex">
              <span
              >凭证：
                <el-image
                    style="width: 50px; height: 50px; margin-right: 5px"
                    v-for="(item, index) in overdueData.picture"
                    :src="'https://' + item"
                    :key="index"
                    :preview-src-list="['https://' + item]"
                ></el-image
                ></span>
            </p>
          </div>
        </el-dialog>
        <!--    录入订单-->
        <addOrder ref="addOrder" @addStatus="receiveMessage"></addOrder>
        <!--    验收记录-->
        <acceptance-record
            ref="recordList"
            style="position: absolute"
        ></acceptance-record>
        <!--    上传合同-->
        <contract
            ref="contract"
            style="position: absolute"
            @submitContract="submitContract"
        ></contract>
        <!--    回款-->
        <receive-img-list ref="receiveImgList" style="position: absolute"/>
        <!--    用户评分-->
        <user-judge ref="userJudge" style="position: absolute"></user-judge>
        <!--    进入监控画面-->
        <open-cctv ref="cctv"></open-cctv>
        <!--    上传cad-->
        <upload-cad ref="cadDialog" @addStatus="receiveMessage"></upload-cad>
        <!--    材料详情-->
        <material-detail ref="materialDialog"></material-detail>
        <!--    cad预览详情-->
        <cadDetail ref="cadDetail"></cadDetail>
        <!--    预结算弹窗-->
        <preSettlement
            ref="settlement"
            @addStatus="receiveMessage"
        ></preSettlement>
        <presettlementAduit
            ref="settlementAduit"
            @addStatus="receiveMessage"
        ></presettlementAduit>
        <settlementUpload
            ref="settlementUpload"
            @addStatus="receiveMessage"
        ></settlementUpload>
        <compound-ruler
            ref="addCad"
            @addStatus="receiveMessage"
        ></compound-ruler>
        <!--    绑定摄像头序列号-->
        <el-dialog
            :visible.sync="bindDialog"
            title="绑定摄像头"
            center
            width="30%"
        >
          <!--      <span style="display: block;margin-bottom: 10px" v-for="(item,index) in serialNumber"-->
          <!--            :key="item+index">序列号{{ index + 1 }}:<el-input clearable v-model="item.No" size="small"-->
          <!--                                                           style="width: 300px"></el-input><i-->
          <!--          class="el-icon-circle-plus" @click="addPlus" style="margin-left: 10px"></i><i class="el-icon-remove"-->
          <!--                                                                                        @click="removePlus(serialNumber,index)"-->
          <!--                                                                                        style="margin-left: 10px"></i></span>-->
          <div style="display: flex;flex-direction: column;align-items: center">
            <div>
              <div style="margin-bottom: 10px">
                当前摄像头列表：{{ this.serial || '空' }}
              </div>
              <span>序列号：<el-input
                  v-model="serialNumber"
                  style="width: 400px"
                  size="small"
              ></el-input></span>
            </div>
          </div>
          <span slot="footer"
          ><el-button @click="submitBinding" style="color: #fff"
          >确 定</el-button
          ></span
          >
        </el-dialog>
        <el-dialog
            :visible.sync="messageTakeDialog"
            title="摄像头运营推送"
            center
            width="50%"
            top="15px"
        >
          <el-table
              :data="cctvTakeList"
              height="calc(100vh - 250px)"
              border
              stripe
              :cell-style="{ textAlign: 'center' }"
              :header-cell-style="{
              'background-color': '#303e9d',
              color: 'white',
              textAlign: 'center',
            }"
          >
            <el-table-column prop="problem" label="截图事项" width=""/>
            <el-table-column prop="createTime" label="时间" width=""/>
            <el-table-column prop="problemRemarks" label="备注" width=""/>
            <el-table-column label="图片" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.problemImg">
                  <el-image
                      style="width: 50px; height: 50px"
                      ref="preview"
                      :src="'https://' + scope.row.problemImg"
                      :preview-src-list="['https://' + scope.row.problemImg]"
                  >
                  </el-image>
                </div>
                <div v-else>-</div>
              </template>
            </el-table-column>
          </el-table>
        </el-dialog>
        <el-dialog
            :visible.sync="messageListDialog"
            title="摄像头抓拍推送"
            center
            width="50%"
            top="15px"
        >
          <div>
            <span
            >事件搜索：<el-select
                v-model="itemSearch"
                style="width: 200px; margin-bottom: 10px"
                size="small"
                clearable
            >
                <el-option value="吸烟" label="吸烟"></el-option>
                <el-option value="安全帽检测" label="安全帽检测"></el-option>
                <el-option value="睡岗" label="睡岗"></el-option>
              </el-select>
              <el-button
                  size="small"
                  style="margin-left: 10px; color: #e6e6e6"
                  @click="getMessage"
              >搜索</el-button
              >
            </span>
          </div>
          <el-table
              :data="messageList"
              height="calc(100vh - 250px)"
              border
              stripe
              :cell-style="{ textAlign: 'center' }"
              :header-cell-style="{
              'background-color': '#303e9d',
              color: 'white',
              textAlign: 'center',
            }"
          >
            <el-table-column prop="taskName" label="抓拍事项" width=""/>
            <el-table-column prop="createTime" label="时间" width=""/>
            <el-table-column label="图片" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.resultUrl">
                  <el-image
                      style="width: 50px; height: 50px"
                      ref="preview"
                      :src="'https://' + scope.row.resultUrl"
                      :preview-src-list="['https://' + scope.row.resultUrl]"
                  >
                  </el-image>
                </div>
                <div v-else>-</div>
              </template>
            </el-table-column>
          </el-table>
          <el-pagination
              style="padding: 20px 0"
              align="right"
              @size-change="handleSizeMessage"
              @current-change="handleCurrentMessage"
              :current-page="currentPage"
              :page-sizes="[20, 30, 40, 50]"
              layout="total, sizes, prev, pager, next, jumper"
              :total="messageTotal"
          >
          </el-pagination>
        </el-dialog>
        <el-dialog :visible.sync="cadOption" title="CAD上传记录">
          <el-table
              :data="cadOptionList"
              height="calc(100vh - 350px)"
              border
              stripe
              :cell-style="{ textAlign: 'center' }"
              :header-cell-style="{
              'background-color': '#303e9d',
              color: 'white',
              textAlign: 'center',
            }"
          >
            <el-table-column label="CAD文件" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.cadUrl">
                  <el-link
                      ref="preview"
                      style="
                      color: #6788ff;
                      font-size: 13px;
                      text-decoration: underline;
                    "
                      :href="'https://' + scope.row.cadUrl"
                  >下载
                  </el-link>
                </div>
                <div v-else>-</div>
              </template>
            </el-table-column>
            <el-table-column prop="createTime" label="上传时间" width=""/>
            <el-table-column label="类型" width="">
              <template slot-scope="scope">
                <span v-if="scope.row.type == 1">初尺</span>
                <span v-if="scope.row.type == 2">第一次复尺</span>
                <span v-if="scope.row.type == 3">第二次复尺</span>
                <span v-if="scope.row.type == 4">第三次复尺</span>
              </template>
            </el-table-column>
            <el-table-column prop="createUser" label="操作人" width=""/>
            <el-table-column label="审核状态">
              <template v-slot:default="scope">
                <span v-if="scope.row.state==0">未审批</span>
                <span v-if="scope.row.state==1" style="color: #ff4949">已驳回</span>
                <span v-if="scope.row.state==2" style="color: #66b1ff">已通过</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" v-if="authorityList.includes(130)">
              <template v-slot:default="scope">
                <el-link style="color: #66b1ff;text-decoration: underline" v-if="scope.row.state==0"
                         @click="_adiut(scope.row,2)">通过
                </el-link>
                <el-link style="color: #ff4949;text-decoration: underline;margin-left: 15px" v-if="scope.row.state==0"
                         @click="_adiut(scope.row,1)">驳回
                </el-link>
              </template>
            </el-table-column>
          </el-table>
        </el-dialog>
        <el-dialog
            :visible.sync="uploadDesignShow"
            title="上传设计图"
            center
            width="30%"
        >
          <div style="width: 100%;display: flex;justify-content: center">
            <div style="margin-top: 15px">
              <span> 设计图： </span>
              <upload-excel
                  v-if="uploadDesignShow"
                  style="margin-top: 10px"
                  :type="'图纸'"
                  @addStatus="handleUploadSuccess1"
              />
            </div>
          </div>
          <span slot="footer">
            <el-button
                size="small"
                style="color: #666; background-color: #eee"
                @click="uploadDesignShow = false"
            >取 消</el-button
            >
            <el-button size="small" type="primary" @click="submitUploadDesign"
            >确 定</el-button
            >
          </span>
        </el-dialog>
        <el-dialog
            :visible.sync="uploadFinalShow"
            title="上传复尺设计图"
            center
            width="28%"
        >
          <div style="width: 100%;display: flex;justify-content: center">
            <div style="margin-top: 15px">
              <span> 终图: </span>
              <upload-excel
                  v-if="uploadFinalShow"
                  style="margin-top: 10px"
                  :type="'图纸'"
                  @addStatus="handleUploadSuccess2"
              />
            </div>
          </div>
          <span slot="footer">
            <el-button
                size="small"
                style="color: #666; background-color: #eee"
                @click="uploadFinalShow = false"
            >取 消</el-button
            >
            <el-button size="small" type="primary" @click="submitUploadFinal"
            >确 定</el-button
            >
          </span>
        </el-dialog>
        <el-dialog
            :visible.sync="shelvesDialog"
            title="填写货架到货时间"
            center
            width="20%"
        >
          选择日期：
          <el-date-picker
              v-model="goodsShelvesTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
          >
          </el-date-picker>
          <span slot="footer">
            <el-button
                size="small"
                style="color: #666; background-color: #eee"
                @click="shelvesDialog = false"
            >取 消</el-button
            >
            <el-button size="small" type="primary" @click="submitShelves"
            >确 定</el-button
            >
          </span>
        </el-dialog>
        <el-dialog :visible.sync="chooseM" title="选择项目经理" width="20%" center>
          <div style="display: flex;justify-content: center;align-items: center">
            <span>项目经理：</span>
            <el-select
                size="small"
                clearable
                v-model="companyManageDate"
                placeholder="请选择"
            >
              <el-option
                  v-for="(item,index) in companyManage"
                  :key="index"
                  :label="item.userName"
                  :value="item.userId"
              >
              </el-option>
            </el-select>
          </div>
          <span slot="footer">
            <el-button
                style="color: #999; background-color: #eee"
                @click="chooseM = false"
            >取 消</el-button
            >
            <el-button style="color: #eeeeee" @click="_comfirmManager"
            >确 认</el-button
            >
          </span>
        </el-dialog>
        <el-dialog :visible.sync="chooseArea" title="选择仓库" width="25%" center>
          <div style="display: flex;align-items: center;justify-content: center">
            <span>仓库：</span>
            <el-select
                size="small"
                clearable
                v-model="areaDate"
                placeholder="请选择"
                @change="_comfirmArea"
            >
              <el-option
                  v-for="(item,index) in areaList"
                  :key="index"
                  :label="item.areaName"
                  :value="item.areaId"
              >
              </el-option>
            </el-select>
          </div>
          <span slot="footer">
            <el-button
                style="color: #999; background-color: #eee"
                @click="chooseArea = false"
            >取 消</el-button
            >
            <el-button
                style="color: #eeeeee"
                @click="_comfirmOrder"
                v-if="btnShow"
            >确 认</el-button
            >
          </span>
        </el-dialog>
        <assign-tbs v-if="orderList" :tabsList="tabsList"></assign-tbs>
      </div>
      <freezeDialog ref="freezeRef"></freezeDialog>
      <el-dialog :visible.sync="checkFreezeDialog" width="40%" title="冻结记录">
        <el-table :data="freezeRecord">
          <el-table-column prop="assignName" label="订单名称"></el-table-column>
          <el-table-column prop="title" label="标题"></el-table-column>
          <el-table-column prop="reasonName" label="原因"></el-table-column>
          <el-table-column label="时长">
            <template v-slot:default="scope">
              {{ scope.row.day + '天' }}
            </template>
          </el-table-column>
          <el-table-column label="状态">
            <template v-slot:default="scope">
              <span v-if="scope.row.state == 0">待审批</span>
              <span v-if="scope.row.state == 1" style="color: #e6a23c"
              >已驳回</span
              >
              <span v-if="scope.row.state == 2">审批通过</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="150px">
            <template v-slot:default="scope">
              <div v-if="scope.row.state == 0&&authorityList.includes(129)">
                <el-button
                    size="small"
                    style="background-color: #fea523; color: #f3f6fd"
                    @click="pass(scope.row, '1')"
                >
                  驳回
                </el-button>
                <el-button
                    type="primary"
                    size="small"
                    @click="pass(scope.row, '2')"
                >通过
                </el-button
                >
              </div>
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import uploadExcel from '../Pages/componentDialog/uploadExcel.vue'
import addOrder from './componentDialog/addOrder.vue'
import dayjs from 'dayjs'
import acceptanceRecord from './componentDialog/acceptanceRecord.vue'
import receiveImgList from './componentDialog/receiveImgList.vue'
import userJudge from './componentDialog/userJudge.vue'
import openCctv from './componentDialog/openCctv.vue'
import uploadCad from './componentDialog/uploadCad.vue'
import materialDetail from './componentDialog/materialDetail.vue'
import cadDetail from './componentDialog/cadDetail.vue'
import contract from './componentDialog/contract.vue'
import quinn from '../../utils/quinn'
import store from '../../store'
import preSettlement from './componentDialog/preSettlement.vue'
import {mapState} from 'vuex'
import presettlementAduit from './componentDialog/presettlementAduit.vue'
import settlementUpload from './componentDialog/settlementUpload.vue'
import compoundRuler from './componentDialog/compoundRuler.vue'
import freezeDialog from './componentDialog/freezeDialog.vue'
import assignTbs from './assignTbs.vue'

export default {
  name: 'orderList',
  components: {
    addOrder,
    assignTbs,
    acceptanceRecord,
    receiveImgList,
    userJudge,
    openCctv,
    uploadCad,
    materialDetail,
    cadDetail,
    contract,
    preSettlement,
    presettlementAduit,
    settlementUpload,
    compoundRuler,
    uploadExcel,
    freezeDialog,
  },
  meta: {
    title: '订单列表',
    icon: 'el-icon-edit-outline',
    authorityList: 100,
    sort: 5,
    keepAlive: false
  },
  data() {
    return {
      tabsList: {
        supplierType: '',
        assignTaskId: '',
      },
      company: '',
      areaDate: '',
      btnShow: false,
      visible: false,
      checkFreezeDialog: false,
      dataTree: [
        {
          label: '店铺列表',
          icon: 'el-icon-s-goods',
          children: [],
          disabled: true,
        },
      ],
      defaultProps: {
        children: 'children',
        label: 'label',
        disabled: 'disabled'
      },
      supplierStateMap: {
        ...{
          1: '待供应商确认订单',
          2: '待上传预算文件',
          3: '预算待审核',
          4: '待开工',
          5: '项目进行中',
          6: '完成待验收',
          7: '待上传结算文件',
          8: '结算待审核',
          9: '已完成',
        },
      },
      StateMap: {
        ...{
          0: '待确认订单',
          1: '已确认订单/待测量(初尺)',
          2: '已测量/待签订合同',
          3: '已签订合同/待合同付款',
          4: '部分付款/继续支付',
          5: '已合同付款/待开工 ',
          6: '进行中',
          7: '已逾期',
          8: '已完成/待验收',
          9: '已验收',
          10: '已完工',
        },
      },
      uploadDesign: '',
      loading: false,
      assignTaskName: '',
      supplierType: '',
      areaList: [],
      assignTaskCode: '',
      companyManageDate: '',
      goodsShelvesTime: '',
      uploadDesignShow: false,
      uploadFinalShow: false,
      chooseM: false,
      uploadFinal: '',
      dispatchTime: '',
      serialNumber: '',
      itemSearch: '',
      messageId: '',
      messageTotal: 0,
      serial: [],
      brandPartyId: '',
      cadOptionList: [],
      cctvTakeList: [],
      inviteUserDialog: false,
      cadOption: false,
      messageListDialog: false,
      messageTakeDialog: false,
      shelvesDialog: false,
      processDialog: false,
      bindDialog: false,
      chooseArea: false,
      orderList: {
        designDrawing: '',
      },
      messageList: [],
      authorityList: [],
      companyManage: [],
      currentPage: 1,
      totalCount: 0,
      getTaskId: '',
      MassignTaskId: '',
      editData: {},
      overdueData: {},
      companyList: [],
      freezeRecord: [],
      params: {
        pageSize: 20,
        pageNumber: 1,
        assignName: '',
      },
      showData: null,
    }
  },
  computed: {
    ...mapState(['userData']),
  },
  async created() {
    const {authorityList = []} =
    quinn.getStorage('userDatav3') || store.state.userData || {}
    this.authorityList = authorityList
    await this.getStoreList()
  },
  activated() {
    // 每次页面激活时检查是否需要刷新
    if (!this.$route.meta.keepAlive) {
      this.getStoreList()
    }
  },
  methods: {
    // getStoreList() {
    //   this.$api.inspectionTaskGetAllAssignTaskList({assignTaskName: this.assignTaskName}).then(res => {
    //     res.map(a => {
    //       a.label = a.assignTaskName
    //       a.id = a.assignTaskId
    //     })
    //     this.dataTree[0].children = res
    //   })
    // },
    _adiut(row, type) {
      const data = {
        cadLogId: row.cadLogId,
        state: type
      }
      this.$api.assignApprovalCad(data).then(res => {
        if (res == 1) {
          this.$message.success("审核成功！")
          this.cadOption = false
        }
      })
    },
    checkFreeze(val) {
      this.$api
          .frozenGetFrozenList({pageNumber: 1, pageSize: 1000, assignName: val})
          .then((res) => {
            this.freezeRecord = res.data
            this.checkFreezeDialog = true
          })
    },
    pass(row, val) {
      const data = {
        frozenId: row.id,
        state: val,
      }
      this.$api.frozenUpdateFrozenState(data).then((res) => {
        if (res == 1) {
          this.visible = false
          this.$message.success('提交成功！')
          this.$api
              .frozenGetFrozenList({
                pageNumber: 1,
                pageSize: 1000,
                assignName: this.orderList.assignName,
              })
              .then((res) => {
                this.freezeRecord = res.data
              })
          this.getOrderList()
        }
      })
    },
    getCompany(val) {
      this.supplierType = val
      this.getOrderList()
    },
    getStoreList() {
      const params = {
        pageSize: 1000,
        pageNumber: 1,
        storeName: this.assignTaskName,
        storeCode: this.assignTaskCode,
      }
      this.$api.storeGetStoreVo(params).then((res) => {
        res.data.map((a, i) => {
          a.label = i + 1 + ' : ' + a.storeName
          a.id = a.storeId
        })
        this.dataTree[0].children = res.data
        // this.storeId = res.data[0].storeId
        //页面初始化storeId为空  默认选中第一个店铺
        if (!this.storeId) {
          this.$nextTick(() => {
            if (res.data.length) {
              const firstStoreId = res.data[0].storeId
              // this.storeId = firstStoreId
              this.$refs.treeRef.setCurrentKey(firstStoreId)
              //触发点击事件
              this.brandPartyId = res.data[0].brandPartyId
              this.handleNodeClick(res.data[0])
            }
          })
        } else {
          this.$nextTick(() => {
            this.$refs.treeRef.setCurrentKey(this.storeId)
            this.handleNodeClick({storeId: this.storeId, brandPartyId: this.brandPartyId})
          })
          //  选择了storeId后  页面刷新 店铺选中不变
        }
      })
    },
    renderContent(h, {node, data, store}) {
      return h('span', {class: 'custom-tree-node'}, [
        h('i', {class: data.icon, style: {marginRight: '6px'}}),
        h('span', data.label),
      ])
    },
    handleNodeClick(val) {
      if (val.label == '店铺列表') return
      this.loading = true
      if (val !== null && typeof val === 'object') {
        this.storeId = val.storeId
        this.brandPartyId = val.brandPartyId
      }
      this.getOrderList()
    },
    _reset() {
      this.dispatchTime = []
      this.params.assignName = ''
      this.params.startTime = ''
      this.params.endTime = ''
      this.params.pageNumber = 1
      this.getOrderList()
    },
    _comfirmManager() {
      this.$confirm('项目开工后不可更改，请确认！', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
          .then(() => {
            this.$api
                .assignUpdateBindProjectUserId({
                  projectUserId: this.companyManageDate,
                  assignTaskId: this.MassignTaskId,
                })
                .then((e) => {
                  this.$message.success('操作成功')
                  this.chooseM = false
                  this.getOrderList()
                })
          })
          .catch(() => {
          })
    },
    _comfirmArea(val) {
      const data = {
        areaId: val,
        assignTaskId: this.comfirmAreaId,
      }
      this.$api.assignUpdateAreaId(data).then((res) => {
        if (res == 1) {
          this.btnShow = true
        }
      })
    },
    _comfirmOrder() {
      this.$confirm('核对无误并确认订单？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
          .then(() => {
            this.$api
                .assignUpdateConfirmTaskStatusDto({
                  assignTaskId: this.comfirmAreaId,
                  supplierType: this.supplierType,
                  status: 1,
                })
                .then((res) => {
                  if (res == 1) {
                    this.$message.success('提交成功！')
                    this.getStoreList()
                    this.chooseArea = false
                  }
                })
          })
          .catch(() => {
          })
    },
    submitShelves() {
      const data = {
        assignTaskId: this.assignTaskId,
        goodsShelvesTime: this.goodsShelvesTime,
      }
      this.$api.assignUpdateGoodsShelvesTime(data).then((res) => {
        if (res == 1) {
          this.$message.success('提交成功！')
          this.shelvesDialog = false
          this.getOrderList()
        }
      })
    },
    showDataFn(showKey, row) {
      ;(this[showKey] = true), (this.showData = JSON.parse(JSON.stringify(row)))
    },
    handleUploadSuccess1(val) {
      if (val.type == '图纸') {
        this.uploadDesign = val.file
      }
    },
    downEndDrawing(e) {
      window.open('https://' + e, '_blank')
    },
    handleCommand(command, row) {
      this.$set(row, 'storeId', this.storeId)
      const commandMap = {
        editOrder: () => this.$refs.addOrder.edit(row), //编辑
        applyFreeze: () => this.$refs.freezeRef.handleOpen(row), //申请冻结
        openRecordDialog: () => this.$refs.recordList.handleOpen({
          taskId: row.assignTaskId,
          pageNumber: 1,
          pageSize: 1000000,
        }), //监理验收记录
        confirmOrder: () => {
          // this.$confirm('核对无误并确认订单？', '提示', {
          //   confirmButtonText: '确定',
          //   cancelButtonText: '取消',
          //   type: 'warning',
          // })
          //     .then(() => {
          //       this.$api.assignUpdateConfirmTaskStatusDto({assignTaskId: row.assignTaskId, supplierType:this.supplierType}).then((res) => {
          //         if (res == 1) {
          //           this.$message.success('提交成功！')
          //           this.getStoreList()
          //         }
          //       })
          //     })
          //     .catch(() => {
          //     })
          this.chooseArea = true
          this.$api.assignGetAreaList().then((res) => {
            this.areaList = res
          })
          this.comfirmAreaId = row.assignTaskId
        }, //供应商确认订单
        confirmOrder1: () => {
          this.$confirm('核对无误并确认订单？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
              .then(() => {
                this.$api
                    .assignUpdateConfirmTaskStatusDto({
                      assignTaskId: row.assignTaskId,
                      supplierType: this.supplierType,
                    })
                    .then((res) => {
                      if (res == 1) {
                        this.$message.success('提交成功！')
                        this.getStoreList()
                      }
                    })
              })
              .catch(() => {
              })
        }, //供应商确认订单
        startOrder: () => {
          this.$confirm('订单核对无误并开工？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }).then(() => {
            this.$api
                .assignStartWork({
                  assignTaskId: row.assignTaskId,
                  supplierType: this.supplierType,
                })
                .then((res) => {
                  if (res == 1) {
                    this.$message.success('提交成功！')
                    this.getStoreList()
                  }
                })
          })
              .catch(() => {
              })
        }, //项目经理开工
        uploadCAD: () => this.$refs.cadDialog.handleOpen(row), //上传CAD
        commondDetail: () => this.$refs.userJudge.handleOpen(row.assignTaskId), //用户评价明细
        materialDetail: () => this.$refs.materialDialog.handleOpen(row, 1), //CAD材料明细
        restockDetail: () => this.$refs.materialDialog.handleOpen(row, 2), //补货明细
        cadDeatail: () => this.$refs.cadDetail.handleOpen(row), //CAD预览详情
        cctvBinding: () => {
          this.serial = row.serialNumber
          this.getTaskId = row.assignTaskId
          this.bindDialog = true
          this.serialNumber = ''
        }, //绑定摄像头
        cctvMessageList: () => {
          this.messageId = row.assignTaskId
          this.messageListDialog = true
          this.$api
              .appraiseGetAiMessage({
                assignTaskId: row.assignTaskId,
                pageNumber: 1,
                pageSize: 20,
              })
              .then((res) => {
                this.messageList = res.data
                this.messageTotal = res.total
              })
        },
        cctvTakeListBtn: () => {
          this.messageTakeDialog = true
          this.$api
              .assignGetProblemList({assignTaskId: row.assignTaskId})
              .then((res) => {
                this.cctvTakeList = res
              })
        },
        openContractDialog: () => this.$refs.contract.handleOpen({
          assignTaskId: row.assignTaskId,
          contractId: row.contractId,
          status: row.status,
        }), //
        loadContract: () => {
          const pdfUrl = 'https://' + row.signedContractUrl
          window.open(pdfUrl, '_blank')
        }, //
        coldChain: () => this.$refs.settlement.handleOpen(row, '预算上传'), //预算上传
        presettlementAduit: () => this.$refs.settlementAduit.handleOpen(row), //预结算审核
        settlementUpload: () => this.$refs.settlementUpload.handleOpen(row), //结算上传
        showData: () => {
          this.uploadDesignShow = true
          this.showData = JSON.parse(JSON.stringify(row))
        }, //上传设计图
        showDataFn: () => {
          this.uploadFinalShow = true
          this.showData = JSON.parse(JSON.stringify(row))
        }, //上传复尺设计图
        addCad: () => this.$refs.addCad.handleOpen(row), //添加CAD上传记录
        checkCad: () => {
          this.cadOption = true
          this.$api
              .assignGetCadLogList({assignTaskId: row.assignTaskId})
              .then((res) => {
                this.cadOptionList = res
              })
        }, //CAD上传记录
        shelvesTime: () => {
          this.assignTaskId = row.assignTaskId
          this.shelvesDialog = true
        }, //填写货架到货时间
        chooseManager: () => {
          this.chooseM = true
          this.MassignTaskId = row.assignTaskId
          this.companyManageDate = ''
          this.$api
              .companyGetManagerList({companyId: row.companyId})
              .then((res) => {
                this.companyManage = res
              })
        }, //选择项目经理
      }
      // 执行对应的处理逻辑
      if (commandMap[command]) {
        commandMap[command]()
      } else {
        console.warn(`未处理的 command: ${command}`)
      }
    },
    submitUploadDesign() {
      const data = {
        assignTaskId: this.showData.assignTaskId,
        designDrawing: this.uploadDesign,
      }
      this.$api.assignUpdateDesignDrawing(data).then((res) => {
        if (res == 1) {
          this.$message.success('提交成功！')
          this.uploadDesignShow = false
          this.getOrderList()
        }
      })
    },
    handleUploadSuccess2(val) {
      if (val.type == '图纸') {
        this.uploadFinal = val.file
      }
    },
    submitUploadFinal() {
      const data = {
        assignTaskId: this.showData.assignTaskId,
        endDrawing: this.uploadFinal,
      }
      this.$api.assignUpdateEndDrawing(data).then((res) => {
        if (res == 1) {
          this.$message.success('提交成功！')
          this.uploadFinalShow = false
          this.getOrderList()
        }
      })
    },
    submitContract() {
      this.getOrderList()
    },
    receiveMessage(data) {
      if (data == 1) {
        this.getOrderList()
      }
    },
    handleClose() {
    },
    submitBinding() {
      this.$api
          .appraiseGetAssignTaskInfo({serialNumber: this.serialNumber})
          .then((res) => {
            if (!res.toString()) {
              if (this.serial) {
                const data = {
                  serialNumber: this.serial.concat([this.serialNumber]),
                  assignTaskId: this.getTaskId,
                }
                this.$api
                    .assignUpdateAssignTaskAiSerialNumber(data)
                    .then((res) => {
                      if (res == 1) {
                        this.$message.success('绑定成功！')
                        this.bindDialog = false
                        this.getOrderList()
                      }
                    })
              } else {
                const data = {
                  serialNumber: [this.serialNumber],
                  assignTaskId: this.getTaskId,
                }
                this.$api
                    .assignUpdateAssignTaskAiSerialNumber(data)
                    .then((res) => {
                      if (res == 1) {
                        this.$message.success('绑定成功！')
                        this.bindDialog = false
                        this.getOrderList()
                      }
                    })
              }
            } else {
              this.$confirm(
                  `【${this.serialNumber}】正在【${res[0].assignName}】使用中，是否先解绑？`,
                  '提示',
                  {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                  }
              )
                  .then(() => {
                    this.$api
                        .appraiseUpdateAssignTaskSerialNumber({
                          serialNumber: this.serialNumber,
                          assignTaskId: res[0].assignTaskId,
                        })
                        .then((e) => {
                          this.$message.success('操作成功')
                          this.getOrderList()
                        })
                  })
                  .catch(() => {
                    // 点击取消时的逻辑
                  })
            }
          })
      //同时绑定多个摄像头时使用去重
      // const resultArray = this.serialNumber.map(item => item.No).filter(Boolean);
      // const duplicates = [];
      // const seen = new Set();
      //
      // resultArray.forEach(item => {
      //   if (seen.has(item)) {
      //     duplicates.push(item); // 如果已存在于 `seen` 集合中，则为重复项
      //   } else {
      //     seen.add(item); // 如果不存在于 `seen` 集合中，则添加进去
      //   }
      // });
      //
      // if (duplicates.length > 0) {
      //   return this.$message.warning("存在重复项" + duplicates)
      // }
    },
    getProgressReason(row) {
      this.$api
          .LateReasonGetLateReasonByTaskId({taskId: row.assignTaskId})
          .then((res) => {
            this.overdueData = res
            this.processDialog = true
          })
    },
    handleSizeChange(val) {
      this.params.pageSize = val
      this.getOrderList()
    },
    handleCurrentChange(val) {
      this.params.pageNumber = val
      this.getOrderList()
    },
    getMessage() {
      this.$api
          .appraiseGetAiMessage({
            assignTaskId: this.messageId,
            pageNumber: 1,
            pageSize: 20,
            taskName: this.itemSearch,
          })
          .then((res) => {
            this.messageList = res.data
            this.messageTotal = res.total
          })
    },
    handleSizeMessage(val) {
      this.$api
          .appraiseGetAiMessage({
            assignTaskId: this.messageId,
            pageNumber: 1,
            pageSize: val,
            taskName: this.itemSearch,
          })
          .then((res) => {
            this.messageList = res.data
            this.messageTotal = res.total
          })
    },
    handleCurrentMessage(val) {
      this.$api
          .appraiseGetAiMessage({
            assignTaskId: this.messageId,
            pageNumber: val,
            pageSize: 20,
            taskName: this.itemSearch,
          })
          .then((res) => {
            this.messageList = res.data
            this.messageTotal = res.total
          })
    },
    async getOrderList() {
      const supplierData = await this.$api.budgetGetSupplierTypeVo({brandPartyId: this.brandPartyId})
      this.companyList = supplierData
      if (!this.supplierType) this.supplierType = supplierData[0].type || 1
      const params = {
        ...this.params,
        supplierType: this.supplierType,
        storeId: this.storeId,
      }

      const res = await this.$api.assignGetAssignTaskList(params).then()
      if (res.data) {
        this.orderList = res.data[0]
        this.loading = false
      }
      this.tabsList.supplierType = this.supplierType
      this.tabsList.assignTaskId = this.orderList?.assignTaskId ?? ""
    },
    add() {
      const data = {
        storeId: this.storeId,
        brandPartyId: this.brandPartyId
      }
      this.$refs.addOrder.handleOpen(data)
    },
    cctvOpen(row) {
      this.$api
          .firmCameraGetLiveAddress({serialNumber: row, type: 1})
          .then((res) => {
            this.$refs.cctv.init(
                res,
                row,
                this.orderList.assignTaskId,
                this.orderList
            )
          })
    },
    getDate(val) {
      if (val) {
        this.params.startTime = dayjs(val[0]).format('YYYY-MM-DD')
        this.params.endTime = dayjs(val[1]).format('YYYY-MM-DD')
      } else {
        this.params.startTime = ''
        this.params.endTime = ''
      }
    },
    receiveRecord(row) {
      this.$refs.receiveImgList.handleOpen(row.assignTaskId)
    },
    addPlus() {
      this.serialNumber = [
        ...this.serialNumber,
        {
          No: '',
        },
      ]
    },
    removePlus(list, index) {
      list.splice(index, 1)
    },
  },
}
</script>
<style scoped>
@import '../../assets/css/public.css';

.left {
  width: 20%;
  padding: 10px;
  box-sizing: border-box;
  border-right: 1px solid #eeeeee;
  height: calc(100vh - 250px);
}

/deep/ .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  background-color: #303e9d;
  border: 1px solid #303e9d;
}
</style>
